<template>
	<view class="content p20 pt40">
		<view>
			<car-number-input @numberInputResult="numberInputResult" :defaultStr="defaultNum"></car-number-input>
		</view>
		
		<view class="module-btn u-flex" style="margin-top: 150rpx;">
			<button class="u-f-justify u-reset-button btn" @click="toAdd">确认</button>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				code:'',
				defaultNum: '粤A',
			};
		},
		onLoad() {},
		methods: {
			numberInputResult(e) {
				this.code=e
				console.log('结果--' + e)
			},
			toAdd(){
				
				this.$api.carAdd({code:this.code}, res => {
					if (res.code) {
						this.$common.successToShow('新增成功', () => {
							uni.navigateBack()
						})
					} else {
						this.$common.errorToShow(res.msg)
					}
				})
			}
		}
	};
</script>


<style lang="scss" scoped>
	.btn {
		background: #4CA8E7;
		border-radius: 50rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 30rpx;
		color: #fff;
		width: 100%;
		margin: 0 40rpx;
		height: 90rpx;
	}
</style>